import React, { Component } from 'react'

export default class App extends Component {

  state = {
    count : 1
  }

  render() {
    return (
      <div>
        {this.state.count}
        <button onClick={this.handleAdd1}>add1</button>
      </div>
    )
  }

  handleAdd1 = () => {
    this.setState({
      count: this.state.count + 1
    });
    this.setState({
      count: this.state.count + 1
    });
    this.setState({
      count: this.state.count + 1
    });
  }

}

/*
  setState处在同步的逻辑中，异步更新状态，更新真实dom
  setState处在异步的逻辑中，同步更新状态，同步更新真实dom
  setState 接受第二个参数，第二个参数是回调函数，状态和dom更新完之后会被触发  
*/